<?php

	include("../../includes/ez_sql_core.php");
	include("../../includes/ez_sql_mysql.php");
	if(isset($_POST["nick"], $_POST["password"], $_POST["email"], $_POST["nombre"], $_POST["sexo"], $_POST["nacimiento"], $_POST["ciudad"], $_POST["pais"]))
	{
		 $db = new ezSQL_mysql("root","","biblioteca","localhost");
		 $db->get_results("SELECT *
		 					FROM usuarios
		 					WHERE nick='" . $_POST["nick"] . "' OR
		 					email='". $_POST["email"] . "'");
		 if($db->num_rows == 0)
		 {
		 	$db->query("INSERT INTO usuarios
		 				VALUES ('','" . $_POST["nick"] . "',"
		 					    . "'" . sha1($_POST["password"]) . "',"
		 					    . "'" . $_POST["email"] . "',"
		 					    . "'" . $_POST["nombre"] . "',"
		 					    . "'" . $_POST["sexo"] . "',"
		 					    . "'" . $_POST["nacimiento"] . "',"
		 					    . "'" . $_POST["ciudad"] . "',"
		 					    . "'" . $_POST["pais"] . "')");
		 	echo "ok";
		 }else{
		 	echo "El nick o el email introducidos ya existen";
		 }
	}
?>